using System;

using Microsoft.Cci;
using Microsoft.FxCop.Sdk.Introspection;

namespace Tyng.Rules
{
    public abstract class FieldRuleBase<T> : RuleBase<T>
        where T : FieldRuleBase<T>
    {
        protected FieldRuleBase()
        {
        }

        public override sealed ProblemCollection Check(Member member)
        {
            Field field = member as Field;
            ProblemCollection returnValue = new ProblemCollection(this);

            if (field == null || !ShouldCheckField(field))
                return null;

            return Check(field);
        }

        protected virtual bool ShouldCheckField(Field field)
        {
            return true;
        }

        protected abstract ProblemCollection Check(Field field);

    }
}
